class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int result = 0;
        int i = 0;
        for (i = 0; i < 32; i++)
        {
            int count = 0;
            for (int e : nums)
            {
                count += (e >> i) & 1;
            }
            if (count % 3 != 0)
                result = result | (1 << i);
        }
        return result;
    }

};